package com.jinduplan.planmanager.mvp.presenter

import com.cxz.kotlin.baselibs.ext.ss
import com.cxz.kotlin.baselibs.ext.sss
import com.cxz.kotlin.baselibs.http.HttpStatus
import com.cxz.kotlin.baselibs.http.exception.ExceptionHandle
import com.cxz.kotlin.baselibs.mvp.BasePresenter
import com.cxz.kotlin.baselibs.rx.SchedulerUtils
import com.fphoenixcorneae.util.toast.ToastUtil
import com.jinduplan.planmanager.mvp.contract.MainContract
import com.jinduplan.planmanager.mvp.contract.ProjectContract
import com.jinduplan.planmanager.mvp.contract.ProjectUploadContract
import com.jinduplan.planmanager.mvp.contract.ProjectUploadSignContract
import com.jinduplan.planmanager.mvp.model.MainModel
import com.jinduplan.planmanager.mvp.model.ProjectModel
import com.jinduplan.planmanager.mvp.model.ProjectUploadModel
import com.jinduplan.planmanager.mvp.model.ProjectUploadSignModel

/**
 * @author admin
 * @date 2018/11/20
 * @desc
 */
class ProjectUploadSignPresenter : BasePresenter<ProjectUploadSignContract.Model, ProjectUploadSignContract.View>(), ProjectUploadSignContract.Presenter {

    override fun createModel(): ProjectUploadSignContract.Model? = ProjectUploadSignModel()
    override fun uploadInPic(file: String) {
        mModel?.uploadPic(file)?.ss(mModel, mView, onSuccess = {
            mView?.uploadPicSuccess(it.data.signature)
        }, onError = {
            ToastUtil.show(it.msg)
        })
    }

    override fun sign(file: String, daily_construction_id: String, signature_date: String) {
        mModel?.sign(file,daily_construction_id,signature_date)?.ss(mModel, mView, onSuccess = {
            mView?.projectSignSuccess(it.data)
        }, onError = {
            ToastUtil.show(it.msg)
        })
    }


}